//
//  QueryCarBrandCell.m
//  carcareIOS
//
//  Created by 王然 on 16/8/2.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "BRCarInfoCarBrandCell.h"

#define CELL_HEIGHT (60)

#define Word_Color (COLOR_HEXSTRING(@"#424242"))

#define Word_Wrong_Color (COLOR_HEXSTRING(@"#fd6500"))


@interface BRCarInfoCarBrandCell()

@property (nonatomic , strong) UILabel * leftL;
@end

@implementation BRCarInfoCarBrandCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}
- (void)createUI
{
    CGFloat labelX = 15 * __MAIN_RATIO_375;
    
    CGFloat leftLW = 80;
    self.leftL = [[UILabel labelWithFrame:CGRectMake(labelX, 0, leftLW, CELL_HEIGHT) font:FONT_DEFAULT_Light(16) text:@"车牌号码" textColor:[Theme wordColor]] setupOnView:self];
    
    CGFloat rightTFW = 70;
    CGFloat rightTFL = __MAIN_WIDTH - rightTFW - labelX;
    self.rightTF = [[UITextField textFieldWithFrame:CGRectMake(rightTFL, 0, rightTFW, CELL_HEIGHT) textColor:Word_Color font:FONT_DEFAULT_Light(15)] setupOnView:self];
    self.rightTF.textAlignment = NSTextAlignmentRight;
    self.rightTF.keyboardType = UIKeyboardTypeASCIICapable;
    self.rightTF.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
    self.rightTF.placeholder = @"车牌号码";
    
    CGFloat cityVW = 45;
    UIView * cityV = [[UIView viewWithFrame:CGRectMake(self.rightTF.left - cityVW, 0, cityVW, CELL_HEIGHT)] setupOnView:self];
    cityV.backgroundColor = [UIColor clearColor];
    
    self.simpleCityL = [[UILabel labelWithFrame:CGRectMake(0, 0, 23, cityV.height) font:FONT_DEFAULT_Light(15) text:@"" textColor:[Theme mainNavColor]] setupOnView:cityV];
    
    UIImage * cityImage = ImageNamed(@"QueryChangeCityImage");
    self.cityImageV = [[UIImageView imageViewWithCenter:CGPointMake(self.simpleCityL.right + cityImage.size.width / 2, cityV.height / 2) image:cityImage] setupOnView:cityV];
    
    
    __weak __typeof(self) wself = self;
    [[UIButton buttonEmptyWithFrame:cityV.bounds click:^{
        if (wself.cityVClick) wself.cityVClick();
    }] setupOnView:cityV];
    
    [[[UIView viewWithFrame:CGRectMake(0, 0, __MAIN_WIDTH, 0.5)] setupOnView:self] resetBackgroundColor:[Theme lineColor]];
}
- (void)reloadTextColorIsWrong:(BOOL)isWrong
{
    [self.leftL setTextColor:(isWrong ? Word_Wrong_Color : Word_Color)];
    
    [self.rightTF setTextColor:(isWrong ? Word_Wrong_Color : Word_Color)];

}
+ (CGFloat)getCellHeight
{
    return CELL_HEIGHT;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
